#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+10;
string s[N];
struct ACAM{
    int to[N][26];
    int fail[N];
    int dis[N];
    int cnt[N];
    int pcnt;
    int rot;
    int gen(){
        int now = ++pcnt;
        memset(to[now],0,sizeof(to[now]));
        fail[now] = 0;
        cnt[now] = 0;
        dis[now] = 0;
        return now;
    }
    void init(){
        pcnt = 0;
        rot = gen();
        dis[rot] = 0;
    }
    void insert(string s){
        int now = rot;
        for(char c : s){
            c -= 'a';
            if(!to[now][c]){
                to[now][c] = gen();
                dis[to[now][c]] = dis[now] + 1;
            }
            now = to[now][c];
            cnt[now]++;
        }
    }
    void build(){
        int now = rot;
        queue<int> que;
        for(int i = 0;i < 26;i++){
            if(to[rot][i])
            {
                que.push(to[rot][i]);
                fail[to[rot][i]] = rot;
            }else{
                to[rot][i] = rot;
            }
        }
        while(que.size()){
            int now = que.front();
            que.pop();
            for(int i = 0;i < 26;i++){
                if(to[now][i]){
                    que.push(to[now][i]);
                    fail[to[now][i]] = to[fail[now]][i];
                }else{
                    to[now][i] = to[fail[now]][i];
                }
            }
        }
    }
}acam;
int f[N];
int g[N];
int main(){
    string t;
    cin>>t;
    int n;
    cin>>n;
    for(int i = 1;i<=n;i++){
        cin>>s[i];
    }
    acam.init();
    for(int i = 1;i <= n;i++){
        acam.insert(s[i]);
    }
    acam.build();
    int cur = acam.rot;
    for(char c : t){
        cur = acam.to[cur][c - 'a'];
    }
    while(cur){
        f[n - acam.dis[cur] + 1] += acam.cnt[cur];
        cur = acam.fail[cur];
    }
    acam.init();
    for(int i = 1;i <= n;i++){
        reverse(s[i].begin(),s[i].end());
        acam.insert(s[i]);
    }
    reverse(t.begin(),t.end());
    cur = acam.rot;
    for(char c : t){
        cur = acam.to[cur][c - 'a'];
    }
    while(cur){
        g[acam.dis[cur]] += acam.cnt[cur];
        cur = acam.fail[cur];
    }
    long long ans = 0;
    for(int i = 0;i<=t.size();i++){
        ans += f[i]*g[i + 1];
    }
    cout<<ans<<'\n';
}